package com.gaoxin.api.service.statisservice;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gaoxin.api.dao.statismapper.StatisExamFailCourseMapper;
import com.gaoxin.api.entity.statisentity.StudentInfo;
import com.google.common.collect.Maps;

@Service
public class StatisExamFailCourseService {
	@Autowired
	private StatisExamFailCourseMapper statisExamFailCourseMapper;
	/**
	 * 查询学生考试不及格科目
	 * @param stuNumber
	 * @param semester
	 * @return
	 */
	public StudentInfo queryFailedStuCourse(String stuNumber,String semester)throws Exception{
		Map<String,String> map = Maps.newHashMap();
		
		if(semester!=null){
			String [] arr = semester.split("_");
			map.put("year", arr[0]);
			if(arr.length>1){
				map.put("term", arr[1]);
			}
		}
		
		map.put("stuNumber", stuNumber);
		String depict = statisExamFailCourseMapper.queryPassRate();
		String minScore = depict.split("-")[0];
		map.put("score", minScore);
		StudentInfo studentInfo = statisExamFailCourseMapper.queryFailedStuCourse(map);
		return studentInfo;
	}
	/**
	 * 查询该学生是否存在
	 * @return
	 */
	public StudentInfo queryStudent(String stuNumber){
		return statisExamFailCourseMapper.queryStudent(stuNumber);
	}
}
